package javaAPI.StringPractice;

import java.util.Scanner;

public class Stringpractice2 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请手动输入一个字符串");
        String strA=sc.next();
        System.out.println("请在此手动输入一个字符串");
        String strB=sc.next();


        boolean result=check(strA,strB);
        System.out.println(result);
    }
    public static boolean check(String strA,String strB){
        for (int i = 0; i < strA.length(); i++) {
            strA=rotate(strA);
            if (strA.equals(strB)){
                return true;
            }
        }
        return false;
    }
    public static String rotate(String str){
        /*char[]arr=str.toCharArray();//自动变为字符数组;
        char first=arr[0];
        for (int i = 1; i < arr.length; i++) {
            arr[i-1]=arr[i];
        }//将所有索引向前移一位
        arr[arr.length-1]=first;
        String result=new String(arr);
        return result;*/
        char first=str.charAt(0);
        String end=str.substring(1);
        return end+first;
    }
}
